package com.chenju.javastatic.common.response;

public class ResponseEntity {

    public int code;
    public String msg;
    public Object data;

    public ResponseEntity(){

    }

    public ResponseEntity(int code, String msg, Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResponseEntity success(){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setResponseCode(ResponseCode.SUCCESS);
        return responseEntity;
    }

    public static ResponseEntity success(Object data){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setResponseCode(ResponseCode.SUCCESS);
        responseEntity.setData(data);
        return responseEntity;
    }

    public static ResponseEntity fail(){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setResponseCode(ResponseCode.FAIL);
        return responseEntity;
    }

        public static ResponseEntity fail(Object data){
            ResponseEntity responseEntity = new ResponseEntity();
            responseEntity.setResponseCode(ResponseCode.FAIL);
            responseEntity.setData(data);
            return responseEntity;
    }

    public void setResponseCode(ResponseCode responseCode){
        this.code = responseCode.getCode();
        this.msg = responseCode.getMsg();
    }

    public void setCode(int code){
        this.code = code;
    }

    public void setMsg(String msg){
        this.msg = msg;
    }

    public void setData(Object data){
        this.data = data;
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }

    public Object getData(){
        return data;
    }
}
